
local M = {}

local C2GS = {}     -- {msg_id : {module, msg_name}}
local GS2C = {}     -- {msg_id : {module, msg_name}}
M.C2GS = C2GS
M.GS2C = GS2C

local C2GS_BY_NAME = {}     -- {msg_name : msg_id}
local GS2C_BY_NAME = {}     -- {msg_name : msg_id}
M.C2GS_BY_NAME = C2GS_BY_NAME
M.GS2C_BY_NAME = GS2C_BY_NAME

local C2GS_DEFINES = {}

--C2GS BEGIN

C2GS_DEFINES.base =
{
    C2SHeartBeat         = 0x0101,
    C2SGMParse           = 0x0103,
}

C2GS_DEFINES.battle =
{
    C2SBattleReady       = 0x0602,
    C2SBattleSubmit      = 0x0607,
}

C2GS_DEFINES.channel =
{
    C2SChannelVariedInfo = 0x0303,
    C2SChannelJoin       = 0x0305,
    C2SChannelPlayerList = 0x0307,
}

C2GS_DEFINES.chat =
{
    C2SChat              = 0x0901,
}

C2GS_DEFINES.friend =
{
    C2SFriendApply       = 0x0703,
    C2SFriendVerifyComfirm = 0x0705,
    C2SFriendDel         = 0x0707,
    C2SFriendShield      = 0x0709,
    C2SFriendUnshield    = 0x070B,
    C2SFriendFollow      = 0x0712,
    C2SFriendInvite      = 0x0713,
    C2SFriendGifts       = 0x0714,
    C2SFriendNotes       = 0x0715,
    C2SFriendRecommend   = 0x0717,
    C2SFriendDegrade     = 0x071A,
    C2SLookOtherFriendInfo = 0x071C,
}

C2GS_DEFINES.gamescene =
{
    C2SSceneJoin         = 0x0E01,
    C2SSceneMove         = 0x0E03,
    C2SSceneStatusChg    = 0x0E05,
    C2SSceneChgDir       = 0x0E0A,
}

C2GS_DEFINES.guild =
{
    C2SGuildList         = 0x0801,
    C2SGuildApply        = 0x0803,
    C2SGuildApplyCancel  = 0x0804,
    C2SGuildCreate       = 0x0806,
    C2SGuildConfirm      = 0x080A,
    C2SGuildQuit         = 0x080B,
    C2SGuildKick         = 0x080C,
    C2SGuildDismiss      = 0x080D,
    C2SGuildSetAdmin     = 0x0811,
    C2SGuildCancelAdmin  = 0x0812,
    C2SGuildTransfer     = 0x0813,
    C2SGuildCancelTransfer = 0x0814,
    C2SGuildModify       = 0x0816,
}

C2GS_DEFINES.item =
{
    C2SItemUse           = 0x0503,
    C2SItemFashionChange = 0x0504,
    C2SItemFashionUnload = 0x0505,
}

C2GS_DEFINES.login =
{
    C2SLoginAccount      = 0x1001,
    C2SCreateRole        = 0x1003,
    C2SLoginRole         = 0x1005,
    C2SLogout            = 0x1007,
    C2SReLoginRole       = 0x1008,
    C2SEnterGame         = 0x1009,
    C2SRandName          = 0x100E,
}

C2GS_DEFINES.mail =
{
    C2SMailOpen          = 0x0A03,
    C2SMailGetAttach     = 0x0A04,
    C2SMailDelete        = 0x0A06,
}

C2GS_DEFINES.newactive =
{
    C2SGetEveryDayLoginInfo = 0x1201,
    C2SGetEveryDayLoginRwd = 0x1203,
}

C2GS_DEFINES.newgift =
{
    C2SPlayerGiftPackInfo = 0x1301,
    C2SBuyGiftPack       = 0x1303,
}

C2GS_DEFINES.newtask =
{
    C2STaskGetReward     = 0x1103,
    C2SActiveGetReward   = 0x1105,
    C2SFinishTask        = 0x1106,
}

C2GS_DEFINES.player =
{
    C2SPlayerReName      = 0x0201,
    C2SPlayerReSign      = 0x0203,
    C2SPlayerBirthday    = 0x0207,
    C2SPlayerRePhoto     = 0x0209,
    C2SPlayerSearch      = 0x020C,
    C2SLookOtherPlayerInfo = 0x02A7,
    C2SPlayerCharge      = 0x02A9,
    C2SUpGrade           = 0x02AB,
    C2SUpLoverLevel      = 0x02B1,
    C2SExChangeDiamondbind = 0x02B3,
}

C2GS_DEFINES.rank =
{
    C2SGetRankInfo       = 0x0B01,
    C2SGetRankByID       = 0x0B03,
}

C2GS_DEFINES.room =
{
    C2SRoomCreate        = 0x0401,
    C2SRoomList          = 0x0403,
    C2SRoomInfo          = 0x0405,
    C2SRoomFind          = 0x0407,
    C2SRoomJoin          = 0x0409,
    C2SRoomLeave         = 0x040B,
    C2SRoomLockSeat      = 0x040E,
    C2SRoomTransfer      = 0x0410,
    C2SRoomKickout       = 0x0412,
    C2SRoomModify        = 0x0413,
    C2SRoomInvite        = 0x0415,
    C2SRoomRecruit       = 0x0416,
    C2SRoomSwitch        = 0x0417,
    C2SRoomReady         = 0x0418,
    C2SRoomBGMList       = 0x041A,
    C2SRoomMusicList     = 0x041C,
}

C2GS_DEFINES.shop =
{
    C2SBuy               = 0x0C01,
    C2SShopCarList       = 0x0C03,
    C2SAddToShopCar      = 0x0C05,
    C2SRemoveFromShopCar = 0x0C07,
    C2SModShopCarItem    = 0x0C09,
    C2SPayShopCar        = 0x0C0B,
    C2SShopItemList      = 0x0C0D,
}

C2GS_DEFINES.vip =
{
    C2SPlayerVipInfo     = 0x0F01,
    C2SPlayerVipGift     = 0x0F03,
}

C2GS_DEFINES.wedding =
{
    C2SWeddingReady      = 0x0D02,
    C2SWeddingSubmit     = 0x0D08,
}

--C2GS END

local GS2C_DEFINES = {}

--GS2C BEGIN

GS2C_DEFINES.base =
{
    S2CHeartBeat         = 0x0102,
    S2CGMParse           = 0x0104,
    S2CNotifyCode        = 0x0105,
    S2CErrText           = 0x0106,
    S2CSystemNotify      = 0x0107,
    S2CBigPacket         = 0x0108,
}

GS2C_DEFINES.battle =
{
    S2CBattleEnter       = 0x0601,
    S2CBattleStart       = 0x0603,
    S2CBattleRoundReady  = 0x0604,
    S2CBattleRoundCountDown = 0x0605,
    S2CBattleRoundStart  = 0x0606,
    S2CBattleSubmit      = 0x0608,
    S2CBattleSettle      = 0x0609,
    S2CBattleLeave       = 0x060A,
}

GS2C_DEFINES.channel =
{
    S2CChannelFixInfo    = 0x0302,
    S2CChannelVariedInfo = 0x0304,
    S2CChannelPlayerList = 0x0308,
}

GS2C_DEFINES.chat =
{
    S2CChat              = 0x0902,
    S2CChatHist          = 0x0903,
}

GS2C_DEFINES.friend =
{
    S2CFriendLogin       = 0x0702,
    S2CFriendVerifyList  = 0x0704,
    S2CFriendAdd         = 0x0706,
    S2CFriendDel         = 0x0708,
    S2CFriendShield      = 0x070A,
    S2CFriendUnshield    = 0x070C,
    S2CFriendOnline      = 0x070D,
    S2CFriendOffline     = 0x070E,
    S2CFriendRecommend   = 0x0718,
    S2CFriendChg         = 0x0719,
    S2CFriendInvite      = 0x071B,
    S2CLookOtherFriendInfo = 0x071D,
    S2CFriendApplyList   = 0x071E,
}

GS2C_DEFINES.gamescene =
{
    S2CSceneJoin         = 0x0E02,
    S2CSceneMove         = 0x0E04,
    S2CSceneStatusChg    = 0x0E06,
    S2CScenemate         = 0x0E07,
    S2CScenePos          = 0x0E08,
    S2CSceneDir          = 0x0E09,
    S2CSceneChgDir       = 0x0E0B,
    S2CSceneStatus       = 0x0E0C,
}

GS2C_DEFINES.guild =
{
    S2CGuildList         = 0x0802,
    S2CGuildApply        = 0x0805,
    S2CGuildMainInfo     = 0x0807,
    S2CGuildMemberInfo   = 0x0808,
    S2CGuildApplyList    = 0x0809,
    S2CGuildClear        = 0x080E,
    S2CGuildTransfer     = 0x0815,
    S2CGuildModify       = 0x0817,
}

GS2C_DEFINES.item =
{
    S2CItemList          = 0x0501,
    S2CItemUpdate        = 0x0502,
}

GS2C_DEFINES.login =
{
    S2CLoginAccount      = 0x1002,
    S2CCreateRole        = 0x1004,
    S2CLoginRole         = 0x1006,
    S2CEnterGame         = 0x100A,
    S2CHello             = 0x100B,
    S2CServerGrade       = 0x100C,
    S2CLogout            = 0x100D,
    S2CRandName          = 0x100F,
}

GS2C_DEFINES.mail =
{
    S2CMailLogin         = 0x0A01,
    S2CMailAdd           = 0x0A02,
    S2CMailChange        = 0x0A05,
    S2CMailDelete        = 0x0A07,
}

GS2C_DEFINES.newactive =
{
    S2CGetEveryDayLoginInfo = 0x1202,
}

GS2C_DEFINES.newgift =
{
    S2CGiftPack          = 0x1302,
    S2CBuyGiftPack       = 0x1304,
}

GS2C_DEFINES.newtask =
{
    S2CTaskInfoLogin     = 0x1101,
    S2CTaskInfoUpdate    = 0x1102,
    S2CActiveInfoUpdate  = 0x1104,
}

GS2C_DEFINES.player =
{
    S2CPlayerReName      = 0x0202,
    S2CPlayerReSign      = 0x0204,
    S2CPlayerPropNotify  = 0x0205,
    S2CPlayerRewardTips  = 0x0206,
    S2CPlayerRePhoto     = 0x020A,
    CS2PlayerAddPraise   = 0x020B,
    S2CPlayerSearch      = 0x020D,
    S2CLookOtherPlayerInfo = 0x02A8,
    S2CPlayerCharge      = 0x02AA,
    S2CUpGrade           = 0x02AC,
    S2CUpLoverLevel      = 0x02B2,
    S2CExChangeDiamondbind = 0x02B4,
}

GS2C_DEFINES.rank =
{
    S2CGetRankInfo       = 0x0B02,
    S2CGetRankByID       = 0x0B04,
}

GS2C_DEFINES.room =
{
    S2CRoomList          = 0x0404,
    S2CRoomInfo          = 0x0406,
    S2CRoomJoin          = 0x040A,
    S2CRoomLeave         = 0x040C,
    S2CRoommate          = 0x040D,
    S2CRoomLockSeat      = 0x040F,
    S2CRoomTransfer      = 0x0411,
    S2CRoomModify        = 0x0414,
    S2CRoomReady         = 0x0419,
    S2CRoomBGMList       = 0x041B,
    S2CRoomMusicList     = 0x041D,
    S2CRoomInvite        = 0x041E,
    S2CRoomKickout       = 0x041F,
    S2CRoomPasswd        = 0x0420,
}

GS2C_DEFINES.shop =
{
    S2CBuy               = 0x0C02,
    S2CShopCarList       = 0x0C04,
    S2CAddToShopCar      = 0x0C06,
    S2CRemoveFromShopCar = 0x0C08,
    S2CModShopCarItem    = 0x0C0A,
    S2CPayShopCar        = 0x0C0C,
    S2CShopItemList      = 0x0C0E,
}

GS2C_DEFINES.vip =
{
    S2CPlayerVipInfo     = 0x0F02,
    S2CPlayerVipGift     = 0x0F04,
}

GS2C_DEFINES.wedding =
{
    S2CWeddingEnter      = 0x0D01,
    S2CWeddingStart      = 0x0D03,
    S2CWeddingStage      = 0x0D04,
    S2CWeddingRoundReady = 0x0D05,
    S2CWeddingRoundCountDown = 0x0D06,
    S2CWeddingRoundStart = 0x0D07,
    S2CWeddingSubmit     = 0x0D09,
    S2CWeddingSettle     = 0x0D0A,
    S2CWeddingEnd        = 0x0D0B,
    S2CWeddingTask       = 0x0D0C,
}

--GS2C END


for k, v in pairs(C2GS_DEFINES) do
    for k2, v2 in pairs(v) do
        assert(not C2GS[v2], string.format("netdefines C2GS error %s %s %s", k, k2, v2))
        assert(not C2GS_BY_NAME[k2], string.format("netdefines C2GS_BY_NAME error %s %s %s", k, k2, v2))
        C2GS[v2] = {k, k2}
        C2GS_BY_NAME[k2] = v2
    end
end

for k, v in pairs(GS2C_DEFINES) do
    for k2, v2 in pairs(v) do
        assert(not GS2C[v2], string.format("netdefines GS2C error %s %s %s", k, k2, v2))
        assert(not GS2C_BY_NAME[k2], string.format("netdefines GS2C_BY_NAME error %s %s %s", k, k2, v2))
        GS2C[v2] = {k, k2}
        GS2C_BY_NAME[k2] = v2
    end
end

return M
